﻿@model Physis.Client.Models.Home.LoginModel

@{ Layout = null; }

<!DOCTYPE html>

<html>

<head>

    <meta name="viewport" content="width=device-width" />

    <title>@Model.PageTitle</title>
    

    <!-- Application Styles -->
    
    <link rel="stylesheet" href="~/Assets/Css/Application/Application.css" type="text/css" />

    <link rel="stylesheet" href="~/Assets/Css/Application/NoPrint.css" media="print" type="text/css" />

    <link rel="stylesheet" id="ThemeStylesheet" href="~/Assets/Css/Themes/@Model.ThemeDefault/jquery-ui-1.10.2.min.css" type="text/css" /> <!-- JQUERY UI --> 


    <!-- jQuery and Support Libraries (BUNDLED) -->

    <script src="~/Scripts/Bundle" type="text/javascript"></script>

    
    <style type="text/css">
    
        h3 { background: transparent !important; border: 0px !important; }

        h3 a { white-space: nowrap; }

        h4 { margin-bottom: 6px; }
        
        h4 a { white-space: nowrap; }
        
        .LogoBackground {

            background-position-x: center;

            background-position-y: center;
        
            background-repeat: no-repeat;
        
        }

    </style>
    
</head>
    
<body class="TextNormal">

    <input id="RootUrl" type="hidden" value="@Url.Content("~")" />
    
    <div id="ApplicationTitleBar" class="NoPrint ui-widget-header">

        <table style="width: 100%;">
            
            <tr class="" style="height: 32px;">

                <td style="padding-left: .125in;width: 100%;">Physis</td>

            </tr>

        </table>

    </div>
    
    <div id="theme-rules-expressed" style="display: none;">

        <div id="theme-ui-state-active" class="ui-state-active"></div>

        <div id="theme-ui-state-default" class="ui-state-default"></div>

        <div id="theme-ui-state-hover" class="ui-state-hover"></div>

        <div id="theme-ui-widget-content" class="ui-widget-content"></div>

    </div>

    <div id="ApplicationContent" class="ui-state-default-background ui-state-default-border" style="border-left: none; border-right: none;">
        
        <div id="LoginContent" class="ui-widget-content-background ui-widget-content-color TextNormal" style="margin: .06125in; padding: .125in .06125in .125in .25in; border: solid 1px black;">

            <table style="table-layout: fixed;"><tr>
        
                <td style="width: 40%; text-align: right; padding-right: .25in;">
                    
                    <span style="white-space: nowrap; font-family: 'Segoe Script'; font-size: 28pt;">Quebe Systems</span>

                    <div><span style="white-space: nowrap; font-size: 8pt;">&copy; 2013</span></div>

                </td>
                    
                <td style="border-left: 1px solid; padding-left: .125in; padding-right: .125in;">

                    <div style="min-height: 400px;">
                    
                    @if (Model.AuthenticationResponse.UserAccountId != 0) { 
                        
                        <h3>@Model.AuthenticationResponse.UserDisplayName</h3>
                        
                    }

                    @if (Model.AuthenticationResponse.AuthenticationError == Physis.Security.Enumerations.AuthenticationError.MustSelectEnvironment) {

                        <h4>Environment:</h4>

                        <div>@Html.DropDownList("EnvironmentId", Model.EnvironmentSelectList, new { style="width: 250px;" })</div>
                        
                        <div style="width: 250px; text-align: right; margin-top: 6px;"><a href="javascript:void(0);" onclick="SelectEnvironment_OnClick();">(select)</a></div>
                        
                    }

                    else {
                        
                        <div class="ui-widget">

                            <div style="padding: 0 .7em;" class="ui-state-error ui-corner-all">

                                <p><span style="float: left; margin-right: .3em;" class="ui-icon ui-icon-alert"></span>

		                        <strong>Exception: </strong>@Model.AuthenticationResponse.LastExceptionMessage [@Physis.Data.Functions.PascalString(Model.AuthenticationResponse.AuthenticationError.ToString())]</p>

                            </div>
                        
                        </div>
                        
                    }

                    </div>

                </td>

            </tr></table>

        </div>

    </div>

<script type="text/javascript">

    var isWindowResizing = false;

    function Window_OnResize() {

        if (isWindowResizing) { return; }

        isWindowResizing = true;


        var availableHeight = $(window).innerHeight();

        availableHeight -= $("#LoginContent").offset().top * 2; // REMOVE MARGIN HEIGHT

        availableHeight += 6; // ADD BACK BORDER HEIGHT

        if (availableHeight < 400) { availableHeight = 400; } // MAKE SURE MINIMUM SIZE

        $("#LoginContent").height(availableHeight);

        $("#LoginContent td").height(availableHeight);


        isWindowResizing = false;

    }

    $(document).ready(function () {

        $(window).resize(Window_OnResize);

        $(window).resize();


        $("#EnvironmentId:visible").focus(); // IF THE ENVIRONMENT IS VISIBLE, SET THE FOCUS HERE FIRST 

        $("#EnvironmentId").keypress(function (event) { if (event.which == 13) { SelectEnvironment_OnClick(); event.preventDefault(); } });

    });


    function SelectEnvironment_OnClick() {

        var requestUrl = $("#RootUrl").val() + "Home/Login/" + $("#EnvironmentId").val();

        window.location = requestUrl;

    }


</script>

</body>

</html>
